import urllib2
from BeautifulSoup import BeautifulSoup

site = "Google"
url = "http://www.google.com/"
domains = ["google.com","google.co.uk"]
sessionCookieNames = ["SID","NID","HSID","PREF"]

def processPacket(session):
  if "SID" in session.cookies:
    session.sessionID = session.cookies["SID"]

def identifyUser(site,session):
  try:
    cookies = ''.join([k+"="+session.cookies[k]+";" for k in session.cookies])
    req = urllib2.Request(site.url,headers={'Cookie':cookies,'User-Agent':'Firefox/3.6.3'})
    html = urllib2.urlopen(req).read()
    soup = BeautifulSoup(html)
    session.userName = soup.findAll(attrs={"class":"gb4"})[0].findAll(text=True)[0]
  except:
    pass

